#pragma once

#include <maxplugin/scene_saver.h>
#include <maxplugin/mesh.h>

#include <osg/ref_ptr>

namespace osg
{
	class Geometry;
	class StateSet;
	class Texture2D;
	class Node;
};

class osg_scene_saver : public scene_saver
{
public:
	osg_scene_saver(TimeValue time, bool export_selected);
	virtual ~osg_scene_saver();

	virtual bool save(const char *path);

private:
	typedef std::map<std::string, osg::ref_ptr<osg::Geometry>> osg_mesh_map;
	typedef std::map<std::string, osg::ref_ptr<osg::StateSet>> osg_mtl_map;
	typedef std::map<std::string, osg::ref_ptr<osg::Texture2D>> osg_tex_map;
	typedef osg::ref_ptr<osg::Node> osg_node_ptr;

	osg_node_ptr convert_model(model_ptr model,
		const osg_mesh_map &meshes, const osg_mtl_map &materials);

	osg_mesh_map convert_meshes();
	osg_mtl_map convert_materials();
	osg_tex_map convert_textures();
	void write_skeletons();
};